﻿@using System.Data
@using LiuYan.Web.Areas.Mall.Controllers
@{
    Layout = null;
    Layout = "~/Areas/Mall/Views/Shared/MallLayout.cshtml";
    ViewBag.Title = "搜索结果";
}
   

<div class="search">
    <div class="search_l">
        <input type="text" id="s_text" />
    </div>
    <div class="search_r">
        <img src="/Images/seach.jpg" onclick="search()" />
    </div>
</div>
<div style="width: 100%;height: 30px;font-size: 12px;line-height: 30px;">搜索结果:</div>
        <div class="goodlist">
        
          
      
        </div>


<div style="width: 100%;height: 80px;"></div>


<script>
    var pagecount = 5;
    var pagenum = 0;
    $(window).scroll(function() {
        if ($(document).scrollTop() + $(window).height() >= $(document).height()) {
            pagenum += 1;
            getlist();
        }
    });
    $(function() {
        getlist();
    });
    function getlist() {
        $.post("@Url.Action("GetList")", { pageCount: pagecount, pageIndex: pagenum * pagecount, name: "@ViewData["str"]" }, function (data) {
            var obj = JSON.parse(data);
            var str = "";
            for (var i = 0; i < obj.length; i++) {
                var item = obj[i];
                str += "<a href='/Mall/Goods/GoodDetail?gid=" + item.Id + "'>" +
                    "<img src='" + item.Img1 + "'/>" +
                    "<label>" + item.Name + "</label><br />" +
                    "<label class='goodsprice'>" + item.Price + "</label>&nbsp;&nbsp;" +
                    "<label>销量" + (item.PayCountTrue + item.PayCount) + "</label>" +
                    "</a>";
            }
            $(".goodlist").append(str);
        });
    }
    function search() {
        var str = $("#s_text").val();
        if (str == "") {
            alert("请输入商品名称！");
            return false;
        }
        location.href = "@Url.Action("Index","Search")?str=" + encodeURIComponent(str);
    }
</script>